﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;


namespace CS_BEGINNER_TO_PROFICIENT.DesignPatterns.CreationMode.SingletonPattern
{
    // 饿汉式
    public class SingleObjectHungry
    {
        private static SingleObjectHungry _instance = new SingleObjectHungry();

        private SingleObjectHungry() { }

        public static SingleObjectHungry GetInstance()
        {
            return _instance;
        }

        public void ShowMessage()
        {
            Console.WriteLine("Hello World");
        }

        public static void Execute()
        {
            SingleObjectHungry ob = SingleObjectHungry.GetInstance();
            ob.ShowMessage();
        }
    }
}
